//
//  mAppointmentTableViewCell.m
//  YIJU2.0HD
//
//  Created by URANUS on 16/5/23.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "mAppointmentTableViewCell.h"
#import "mAppointmentModel.h"
#import "Masonry.h"
#import "UILabel+FontAndTextColor.h"
#import "UIButton+ColorandText.h"
#import "Macro.h"

#define mLabelTextColor [UIColor colorWithRed:0.3608 green:0.3608 blue:0.3608 alpha:1.0]

@interface mAppointmentTableViewCell ()
@property (nonatomic, strong)UIView  *TempView;
@property (nonatomic, strong)UILabel *houseCodeLabel;//房屋编号
@property (nonatomic, strong)UILabel *nameLabel;//看房人
@property (nonatomic, strong)UILabel *deteLabel;//看房日期
@property (nonatomic, strong)UILabel *phoneLabel;//手机号
@property (nonatomic, strong)UILabel *personLabel;//看房人数
@property (nonatomic, strong)UILabel *commentsLabel;//备注
@property (nonatomic, strong)UIButton *nextBtn;//下一条按钮
@property (nonatomic, strong)UIButton *sureBtn;//确认按钮

@end

@implementation mAppointmentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupConstraint];
    }
    return self;
}

- (void)setupConstraint {
    [self.TempView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
       
    }];
   
    [self.houseCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.TempView.mas_top).offset(TweentyOffsetViewMargin);
        make.left.equalTo(self.TempView.mas_left).offset(TenOffsetViewMargin);
        make.right.equalTo(self.TempView.mas_right).offset(-TenOffsetViewMargin);
        make.height.equalTo(self.TempView.mas_height).multipliedBy(1/10.0f);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.houseCodeLabel.mas_bottom).offset(TweentyOffsetViewMargin);
        make.left.equalTo(self.houseCodeLabel.mas_left);
        make.right.equalTo(self.houseCodeLabel.mas_right);
        make.height.equalTo(self.TempView.mas_height).multipliedBy(1/10.0f);
    }];
    
    [self.deteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(TweentyOffsetViewMargin);
        make.left.equalTo(self.nameLabel.mas_left);
        make.right.equalTo(self.nameLabel.mas_right);
        make.height.equalTo(self.TempView.mas_height).multipliedBy(1/10.0f);
    }];
    
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.deteLabel.mas_bottom).offset(TweentyOffsetViewMargin);
        make.left.equalTo(self.deteLabel.mas_left);
        make.right.equalTo(self.deteLabel.mas_right);
        make.height.equalTo(self.TempView.mas_height).multipliedBy(1/10.0f);
    }];
    
    [self.personLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phoneLabel.mas_bottom).offset(TweentyOffsetViewMargin);
        make.left.equalTo(self.phoneLabel.mas_left);
        make.right.equalTo(self.phoneLabel.mas_right);
        make.height.equalTo(self.TempView.mas_height).multipliedBy(1/10.0f);
    }];
    
    [self.commentsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.personLabel.mas_bottom).offset(TweentyOffsetViewMargin);
        make.left.equalTo(self.personLabel.mas_left);
        make.right.equalTo(self.personLabel.mas_right);
        make.height.equalTo(self.TempView.mas_height).multipliedBy(1/10.0f);
    }];
   
    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.commentsLabel.mas_bottom).offset(TweentyOffsetViewMargin*2);
        make.left.equalTo(self.contentView.mas_left);
        make.bottom.equalTo(self.contentView.mas_bottom);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(1/2.0f);
        
    }];
    
    [self.sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.commentsLabel.mas_bottom).offset(TweentyOffsetViewMargin*2);
        make.left.equalTo(self.nextBtn.mas_right);
        make.bottom.equalTo(self.contentView.mas_bottom);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(1/2.0f);
        
    }];
    
}

#pragma mark - Getter
- (UIView *)TempView {
    if (!_TempView) {
        _TempView = [UIView new];
        [self.contentView addSubview:_TempView];
    }
    return _TempView;
}

- (UILabel *)houseCodeLabel {
    if (!_houseCodeLabel) {
        _houseCodeLabel = [UILabel lableWithTextFont:sTitle_Font textColor:mLabelTextColor];
        [self.TempView addSubview:_houseCodeLabel];
    }
    return _houseCodeLabel;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel lableWithTextFont:sTitle_Font textColor:mLabelTextColor];
        [self.TempView addSubview:_nameLabel];
    }
    return _nameLabel;
}

- (UILabel *)deteLabel {
    if (!_deteLabel) {
        _deteLabel = [UILabel lableWithTextFont:sTitle_Font textColor:mLabelTextColor];
        [self.TempView addSubview:_deteLabel];
    }
    return _deteLabel;
}

- (UILabel *)phoneLabel {
    if (!_phoneLabel) {
        _phoneLabel = [UILabel lableWithTextFont:sTitle_Font textColor:mLabelTextColor];
        [self.TempView addSubview:_phoneLabel];
    }
    return _phoneLabel;
}

- (UILabel *)personLabel {
    if (!_personLabel) {
        _personLabel = [UILabel lableWithTextFont:sTitle_Font textColor:mLabelTextColor];
        [self.TempView addSubview:_personLabel];
    }
    return _personLabel;
}

- (UILabel *)commentsLabel {
    if (!_commentsLabel) {
        _commentsLabel = [UILabel lableWithTextFont:sTitle_Font textColor:mLabelTextColor];
        [self.TempView addSubview:_commentsLabel];
    }
    return _commentsLabel;
}

- (UIButton *)nextBtn {
    if (!_nextBtn) {
        _nextBtn = [UIButton buttonWithBackgroundColor:[UIColor orangeColor] textFont:sTitle_Font textColor:mLabelTextColor title:@"查看下一条" cornerRadius:0];
        [self.TempView addSubview:_nextBtn];
    }
    return _nextBtn;
}

- (UIButton *)sureBtn {
    if (!_sureBtn) {
        _sureBtn = [UIButton buttonWithBackgroundColor:[UIColor purpleColor] textFont:sTitle_Font textColor:mLabelTextColor title:@"确定预约" cornerRadius:0];
        [self.TempView addSubview:_sureBtn];
    }
    return _sureBtn;
}


#pragma mark - SetModel
- (void)setModel:(mAppointmentModel *)model {
    self.houseCodeLabel.text = [@"房屋编号:   " stringByAppendingString:model.HouseCode];
    self.nameLabel.text = [@"看房人:     " stringByAppendingString:model.name];
    self.deteLabel.text = [@"看房日期:    " stringByAppendingString:model.date];
    self.phoneLabel.text = [@"手机号:    " stringByAppendingString:model.phoneNum];
    self.personLabel.text = [@"看房人数:      " stringByAppendingString:model.peopleNum];
    self.commentsLabel.text = [@"看房备注:    " stringByAppendingString:model.comments];
}



@end
